import tkinter as tk
from tkinter import messagebox

class application(tk.Frame):
    def __init__(self,mast=None):
        self.master=mast
        super().__init__()
        self.creatAPP()

    def creatAPP(self):
        self.music=tk.IntVar()
        self.sport=tk.IntVar()

        l1=tk.Label(self.master,text='hobby').pack(side='left')
        c1=tk.Checkbutton(self.master,text='音乐',variable=self.music,onvalue=1,offvalue=0).pack(side='left')
        c2=tk.Checkbutton(self.master,text='运动',variable=self.sport,onvalue=1,offvalue=0).pack(side='left')
        b1=tk.Button(self.master,text='submit',command=self.pt).pack(side='left')

    def pt(self):
        messagebox.showinfo('爱好',f'爱好music={self.music.get()},sport={self.sport.get()}')

window=tk.Tk()
window.geometry('500x80')
app=application(window)
window.mainloop()
